package com.meng.util;

import java.io.Serializable;

public class ResultUtil<T> implements Serializable {
	private Integer code;
	private String msg="";
	private Long count=0L;
	private T data;

	public ResultUtil() {

	}
	private ResultUtil(Integer code){
		this.code=code;
	}
	private ResultUtil(Integer code,String msg){
		this.code = code;
		this.msg = msg;
	}
	public ResultUtil(Integer code, String msg, T data){
		this.code = code;
		this.msg = msg;
		this.data =data;
	}
	private ResultUtil(Integer code,T data){
		this.code=code;
		this.data = data;
	}




	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Long getCount() {
		return count;
	}

	public void setCount(Long count) {
		this.count = count;
	}

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}

	//成功返回状态码
	public static <T> ResultUtil<T> success(){
		return new ResultUtil<T>(200);
	}
	//成功返回状态码和提示信息
	public static <T> ResultUtil<T> success(String msg){
		return new ResultUtil<T>(200,msg);
	}
    //成功返回状态码和数据
    public static <T> ResultUtil<T> success(T data){
        return new ResultUtil<T>(200,data);
    }
    //成功返回状态码和数据和提示信息
    public static <T> ResultUtil<T> success(String msg,T data){
        return new ResultUtil<T>(200,msg,data);
    }
    //失败提示信息
    public static <T> ResultUtil<T> error(String msg){
        return new ResultUtil<T>(500,msg);
    }

    public static <T> ResultUtil<T> error(Integer code,String msg){
        return new ResultUtil<T>(code,msg);
    }

}
